package com.mundus.world.renderbuffer;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;

public class RenderTarget {
	
	private int _bId;
	private int _internalFormat;
	private int _width;
	private int _height;
	private int _format;
	private int _attachment;
	
	public int getTextureId(){ return _bId;}
	public int getInternalFormat(){ return _internalFormat;}
	public int getWidth(){ return _width;}
	public int getHeight(){ return _height;}
	public int getFormat(){ return _format;}
	public int getAttachment(){ return _attachment;}
	
	public RenderTarget(int internalFormat, int width, int height, int format, int attachment){
		this._internalFormat = internalFormat;
		this._width = width;
		this._height = height;
		this._format = format;
		this._attachment = attachment;
	}
	
	public void initRenderTarget() throws LWJGLException{
		_bId = GL11.glGenTextures();
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, _bId);
		GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, _internalFormat, _width, _height, 0, _format, GL11.GL_FLOAT, (java.nio.ByteBuffer) null);		
		GL30.glFramebufferTexture2D(GL30.GL_DRAW_FRAMEBUFFER, _attachment, GL11.GL_TEXTURE_2D, _bId, 0);
	}
}
